package com.community.web.controller.server;

import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.core.page.TableDataInfo;
import com.community.domain.HealthEntity;
import com.community.service.HealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/health")
public class HealthController extends BaseController {
    @Autowired
    private HealthService healthService;
    @PreAuthorize("@ss.hasPermi('health:health:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthEntity healthEntity) {
        startPage();
        List<HealthEntity> list=healthService.selectHealth(healthEntity);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('health:health:add')")
    @PostMapping("/addHealth")
    public AjaxResult addServeType(@RequestBody HealthEntity healthEntity)
    {
        return toAjax(healthService.addHealth(healthEntity));
    }
    @PreAuthorize("@ss.hasPermi('health:health:edit')")
    @PutMapping("/editHealth")
    public AjaxResult editHealth(@Validated @RequestBody HealthEntity healthEntity)
    {
        return toAjax(healthService.editHealth(healthEntity));
    }
    @PreAuthorize("@ss.hasPermi('health:health:remove')")
    @DeleteMapping("{id}")
    public AjaxResult deleteHealth(@PathVariable int id)
    {
        return toAjax(healthService.deleteHealth(id));
    }
}

